<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 14-5-26
 * Time: 下午9:35
 */
class Musericon extends CI_Model{
    function __construct(){
        parent::__construct();
    }

    function addUserIcon($uid,$iconId)
    {
        $this->deleteUserIcon($uid);
        if(!empty($iconId)){
            $iconIdArr = explode(',',trim($iconId,','));

            foreach($iconIdArr as $value){
                $valueArr[] = "($uid,$value)";
            }
        }
        $valueStr = implode(',',$valueArr);
        if(!empty($valueStr)){
            $sql = "insert into `tbuser_icon`(`uid`,`icon_id`)VALUES$valueStr";
            $this->db->query($sql);
        }

        return $this->db->insert_id();
    }

    function getUserIcon($uid)
    {
        $query = $this->db->get_where('tbuser_icon', array('uid' => $uid));
        return $query->result_array();
    }

    function deleteUserIcon($uid)
    {
        $this->db->delete('tbuser_icon', array('uid' => $uid));
    }


}